<?php
class My_Forms_Admin_Msg extends Zend_Form {
	public function __construct($kid = null, $url = null, $action = null, $uname = null, $uemail = null, $options = null) {
		parent::__construct ( $options );
		$this->setName ( 'msg' )->setAction ( $url );
		
		$username = new Zend_Form_Element_Text ( 'username' );
		if ($uname) {
			$username->setAttribs ( array ('disabled' => 'true' ) );
		}
		$username->setLabel ( 'name:' )->setValue ( $uname );
		
		$ke = new Zend_Form_Element_Select ( 'ke_id' );
		
		$keDb = new Keshi ( );
		$s = $keDb->select ();
		$s->from ( 'bc_keshi', array ('id', 'kename' ) );
		
		$keDb = $keDb->fetchAll ( $s )->toArray ();
		foreach ( $keDb as $v ) {
			$a [] = $v ['id'];
			$b [] = $v ['kename'];
		}
		if ($action == 'updata') {
			$ke->setAttribs ( array ('disabled' => 'true' ) );
		}
		$ke->setLabel ( 'keshi:' )->addMultiOptions ( array_combine ( $a, $b ) )->setValue ( $kid );
		
		$email = new Zend_Form_Element_Text ( 'email' );
		$email->setLabel ( 'email:' )->setValue ( $uemail )->addValidator ( 'EmailAddress' );
		
		$submit = new Zend_Form_Element_Submit ( 'submit' );
		$submit->setLabel ( $action );
		
		$this->addElements ( array ($username, $ke, $email, $submit ) );
	}
}
?>